// 给定一个以数字组成的数组，实现输出id为数字，并且从小到大排序的name（请使用es6语法）
const source = [
    { id: 4, name: 'test1' },
    { id: {}, name: 'ssdf' },
    "test",
    { id: () => { }, name: 'sf' },
    { id: '6', name: 'test3' },
    { id: 6, name: 'test4' },
    { id: 7, name: 'test7' },
    { id: 2, name: 'test2' },
    { name: 'sf' },
    {},
];

const filterSort = function filterSort(source) {
    source = source.filter(item => typeof item?.id === "number");
    source.sort((a, b) => a.id - b.id);
    return source.map(item => item.name);
};

let result = filterSort(source);
console.log(result);
// 输出结果如下 ['test2', 'test1', 'test4', 'test7']